<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .red{
            background: red;
        }
        .green{
            background: green;
        }
        .test{
            width: 100px;
            height: 100px;
            border: 1px solid;
        }
    </style>
</head>
<body>
    <div id="app">
        <!--
            预定义标签属性
            自定义标签属性
            vue指令;后面的数据肯定要去匹配data中的数据的
         -->
        <div :class="color" class="test"   v-text="msg">

        </div>
        <button @click="switchFn">switch</button>
    </div>
</body>
<script src="../../js/vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            msg:"xxxx",
            color:"red"
        },
        methods:{
            switchFn(){
                this.color = this.color === `green` ? `red` : `green`
            }
        }
    })
    
</script>
</html>